package com.jcroke.PC32.datum;

/**
 * @author jcroke
 */

import com.jcroke.PC32.exception.DatumException;

public class dInteger extends Datum {
	
	public dInteger() throws DatumException {
		super(Integer.class, 0);
	}
	
	public dInteger(Integer value) throws DatumException {
		super(Integer.class, value);
	}
	
	public dInteger(Class<?> type, Integer value) throws DatumException {
		super(Integer.class, value);
	}
	
	public dInteger(String value) throws DatumException {
		super(Integer.class, Integer.parseInt(value));
	}
	
	public dInteger(Class<?> type, String value) throws DatumException {
		super(Integer.class, Integer.parseInt(value));
	}

	@Override
	public void add(Object val) throws DatumException {
		this.value = (Integer)this.value + (Integer)val;
	}

	@Override
	public void neg(Object val) throws DatumException {
		this.value = -(Integer)this.value;
	}

	@Override
	public boolean isNull() throws DatumException {
		return (this.value == null);
	}

	@Override
	public void mul(Object val) throws DatumException {
		this.value = (Integer)this.value * (Integer)val;
	}

	@Override
	public void div(Object val) throws DatumException {
		this.value = (Integer)this.value / (Integer)val;
	}

	@Override
	public void mod(Object val) throws DatumException {
		this.value = (Integer)this.value % (Integer)val;
	}

	@Override
	public boolean lt(Object val) throws DatumException {
		return (((Integer)this.value).intValue() < ((Integer)val).intValue());
	}

	@Override
	public boolean ge(Object val) throws DatumException {
		return (((Integer)this.value).intValue() >= ((Integer)val).intValue());
	}

	@Override
	public Class<?> getType() {
		return Integer.class;
	}
	
	@Override
	public Integer getValue() {
		return (Integer)this.value;
	}
}
